<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ page import="jpa.*"%>
<%@ page import="pkg.*"%>
<%@ page import="java.util.*"%>

<%
	IStatelessBean statelessBean = (IStatelessBean) session.getAttribute("statelessBean");
	IStatefulBean statefulBean = (IStatefulBean) session.getAttribute("statefulBean");

	Page currentPage = statefulBean.getCurrentPage();	
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<link href="StyleTest.css" rel="stylesheet" type="text/css" />
	<title><%=currentPage.getPgTitle()%></title>
	<script type="text/javascript">
	
	function resize() {
		var height = window.innerHeight;
		document.getElementById("wrapper").style.height = (height-20)+"px";
		//document.getElementById("content").style.height = (height-220)+"px";
		document.getElementById("subcontent").style.height = (height-320)+"px";
		document.getElementById("footer").style.height = "200px";
		document.getElementById("toolbar").style.height = "200px";
	}
	
	</script>
</head>
<body onload="resize()" onresize="resize()">
	<div id="wrapper">
		<div class="content">
		
		<h1><%=currentPage.getPgTitle()%></h1>
		<div id = "subcontent">
		<%
			//put in a display tag to center the stuff in the subcontent
			if (statelessBean.isMenuPage(currentPage))
			{
				List<Link> menuLinks = statelessBean.getMenuLinks(currentPage);
				for (int i = 0; i < menuLinks.size(); i++)
				{
					Link l = menuLinks.get(i);
					int numberInRow = 3;
					if(i > (menuLinks.size()/3)*3 - 1) numberInRow = menuLinks.size()%3;
					int column = i%3;
					if(numberInRow == 3) 
					{
						%>
						<a href="Controller?do=test&amp;id=<%=l.getPage1().getPgId()%>">
						<div class="menuLink">
						<%=l.getPage1().getPgTitle()%>
						</div>
						</a>
						<%
					}
				}
			} 
			else
			{
				if (statelessBean.isAppletPage(currentPage))
				{
			%>
				<div id="appletdiv">
				<applet <%=currentPage.getPgContent()%>>
					Your browser does not support the <code>applet</code> tag.
				</applet> 
				</div>
			<div id = "test">
			<script type="text/javascript" src="<%=currentPage.getPgContent()%>"></script>
			<%
				}
			
				else if (statelessBean.isImagePage(currentPage))
				{
					%>
					<img src = "<%=currentPage.getPgContent()%>" />
					<%
				}
				else if (statelessBean.isVideoPage(currentPage))
				{
					%>
					<iframe class = "video" width="560" height="315" src="<%=currentPage.getPgContent()%>" frameborder="0" allowfullscreen"></iframe>
					<%
				}
				else if (statelessBean.isTextPage(currentPage))
				{
					%><p class = "textpagetext"><%=currentPage.getPgContent()%></p><%
				}
				
				
				
				
				//Displays caption
				if (currentPage.getPgCaption() != null)
				{
					%><p class = "caption"><%=currentPage.getPgCaption() %></p><%
				}
				
				List<Link> other = statelessBean.getOtherLinks(currentPage);
				if (other.size() > 0)
				{
					%>
					<%
					for (Link l : other)
					{
						%><p>
						<a href="Controller?do=test&amp;id=<%=l.getPage1().getPgId()%>" class="otherlink"><img src="images/SeeAlso.png"/></a>
						</p>
						<%
					}
				}
				
				
				//Shows continue button if applicable
				if(statelessBean.getNextLink(currentPage) != null)
				{
					%>
					<br/><br/>
				<a href = "Controller?do=test&amp;id=<%=statelessBean.getNextLink(currentPage).getPage1().getPgId()%>">
				<%/*<div class="continuebutton">
					<p>Continue</p>
				</div>
				*/ %>
				</a>
				<%}
			}
		
			%>
			</div>
			<p class="clear"/>
		</div>
	<p class="clear">
		
	<div class="footer">
		<%@ include file="toolbar.jsp"%>
		<%//@ include file="footer.jsp"%>
	</div>
	
	</div>
		

</body>
</html>